package com.lntea.mybatisDemo.domain;

import java.io.Serializable;

import org.apache.commons.lang3.StringUtils;

/**
 * @author dev
 */
public class BaseBean implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -3291104610993477517L;

	private static final int ROWS_NUM = 10;

	private Integer page = 1;

	private Integer rows = ROWS_NUM;

	private String sort;

	private String order;

	private String dbType = "oracle";
	private boolean orderDirection = false;
	private Pager pager = new Pager();

	private String startDate; // 开始时间
	private String endDate;// 结束时间

	/**
	 * @return pager
	 */
	public Pager getPager() {
		pager.setPageId(getPage());
		pager.setPageSize(getRows());
		String orderField = "";
		if (StringUtils.isNotBlank(sort)) {
			orderField = sort;
		}
		if (StringUtils.isNotBlank(orderField) && StringUtils.isNotBlank(order)) {
			orderField += " " + order;
		}
		pager.setOrderField(orderField);
		pager.setOrderDirection(getOrderDirection());
		return pager;
	}

	/**
	 * @param orderDirection
	 */
	public void setOrderDirection(boolean orderDirection) {
		this.orderDirection = orderDirection;
	}

	/**
	 * @return orderDirection
	 */
	public boolean getOrderDirection() {
		return orderDirection;
	}

	/**
	 * @param pager
	 *            pager
	 */
	public void setPager(Pager pager) {
		this.pager = pager;
	}

	/**
	 * @return page
	 */
	public Integer getPage() {
		return page;
	}

	/**
	 * @param page
	 *            page
	 */
	public void setPage(Integer page) {
		this.page = page;
	}

	/**
	 * @return rows
	 */
	public Integer getRows() {
		return rows;
	}

	/**
	 * @param rows
	 *            rows
	 */
	public void setRows(Integer rows) {
		this.rows = rows;
	}

	/**
	 * @return sort
	 */
	public String getSort() {
		return sort;
	}

	/**
	 * @param sort
	 *            sort
	 */
	public void setSort(String sort) {
		this.sort = sort;
	}

	/**
	 * @return order
	 */
	public String getOrder() {
		return order;
	}

	/**
	 * @param order
	 *            order
	 */
	public void setOrder(String order) {
		this.order = order;
	}

	/**
	 * @return dbType
	 */
	public String getDbType() {
		return dbType;
	}

	/**
	 * @param dbType
	 *            dbType
	 */
	public void setDbType(String dbType) {
		this.dbType = dbType;
	}

	/*
	 * public String toString() { return
	 * ReflectionToStringBuilder.toString(this,
	 * ToStringStyle.SHORT_PREFIX_STYLE); }
	 */

	public String getStartDate() {
		return startDate;
	}

	public void setStartDate(String startDate) {
		this.startDate = startDate;
	}

	public String getEndDate() {
		return endDate;
	}

	public void setEndDate(String endDate) {
		this.endDate = endDate;
	}
}
